package com.chexiehui.jc.mvp.mine;

import com.chexiehui.jc.Constants;
import com.chexiehui.jc.base.ApiCallback;
import com.chexiehui.jc.base.BaseModel;
import com.chexiehui.jc.base.BasePresenter;
import com.chexiehui.jc.entity.UserInfo;

/**
 * @Description 我的
 * @Auth SongJun
 * @Date 2020/05/21 00:19
 **/
public class MinePresenter extends BasePresenter<MineCovenant.View, MineCovenant.Stores>
        implements MineCovenant.Presenter {

    public MinePresenter(MineCovenant.View view) {
        attachView(view);
    }

    @Override
    public void getUserInfo() {
        addSubscription(appStores.getUserInfo(""),
                new ApiCallback<BaseModel<UserInfo>>(mvpView) {
                    @Override
                    public void onSuccess(BaseModel<UserInfo> model) {
                        if (model.getResultCode() == Constants.REQUEST_OK_CODE
                                && model.getData() != null) {
                            mvpView.onGetUserInfoSuccess(model);
                        } else {
                            onFailure(model.getResultCode(), model.getResultInfo());
                        }
                    }

                    @Override
                    public void onFailure(int code, String msg) {
                        mvpView.onGetUserInfoFailure(new BaseModel<>(code, msg));
                    }
                });
    }

}